/*
ID: majowi1
LANG: JAVA
PROG: beads
*/

import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.io.PrintWriter;


final class beads {

	/**
	 * @param args
	 */
	static char[] necklace;
	static int no_of_beads;
	static int maximum = 0;
	public static void main(String[] args)throws IOException {
		
	    BufferedReader f = new BufferedReader(new FileReader("beads.in"));	    
	    PrintWriter out = new PrintWriter(new BufferedWriter(new FileWriter("beads.out")));
	    no_of_beads = Integer.parseInt(f.readLine().trim());
	    necklace = f.readLine().trim().toCharArray();
	    
	    for (int x = 0; x < no_of_beads; x++){
	    	char[] tempN = getnewSeq(x);
	    	int temp = countFw(tempN) + countFw(getReversedSeq(tempN));
	    	if (temp > maximum)
	    		maximum = temp;	    		
	    }
	    if (maximum > no_of_beads)
	    	maximum = no_of_beads;
	    
	   out.println(maximum);
	   
	   out.close();
	   System.exit(0);
	}
	
	private static int countFw (char[] in){		
		char prev = in[0];
		int count = 1;
		for (int x = 1; x < in.length; x++){
			if (in[x] == prev || in[x] == 'w' || prev == 'w')	
				count++;				
			else
				break;
			if (in[x] != 'w')
				prev = in[x];
		}		
		return count;
	}
	
	private static char[] getnewSeq (int pos){
		if (pos == 0)
			return necklace;
		char[] temp = new char[no_of_beads];		
		for (int x = pos; x < no_of_beads; x++)
			temp[x-pos] = necklace[x];		
		for (int x = 0; x < pos; x++)
			temp[no_of_beads - pos + x] = necklace[x];
		
		return temp;
	}
	
	private static char[] getReversedSeq (char[] in){
		char[] temp = new char[no_of_beads];
		for (int x = 0; x < no_of_beads; x++)
			temp[no_of_beads - 1 - x] = in[x];
		return temp;		
	}

}
